#include<bits/stdc++.h>
#define int long long
using namespace std;
char buf[1<<23],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') f=-1;ch=getchar();}
    while(isdigit(ch)) x=x*10+(ch^48),ch=getchar();
    return x*f;
}
inline void write(int x)
{
    if(!x)
        putchar('0');
    char F[200];
    int tmp=x>0?x:-x;
    if(x<0)
        putchar('-');
    int cnt=0;
    while(tmp>0)
        F[cnt++]=tmp%10+'0',tmp/=10;
    while(cnt>0)
        putchar(F[--cnt]);
}
const int N=1e6+5;
int n,f[N][6];
string s,t;
signed main()
{
	freopen("hard.in","r",stdin);
	freopen("hard.out","w",stdout);
	cin>>n>>s>>t;
	s = ' '+s;
	t = ' '+t;
	f[0][0]=0;
	f[0][1]=f[0][2]=f[0][3]=1;
	f[0][4]=f[0][5]=2;
	for(int i=1;i<=n;i++)
	{
		if(s[i]==t[i])
		{
			f[i][3]=2e18;
			f[i][0]=min({f[i-1][0],f[i-1][1],f[i-1][2],f[i-1][3],f[i-1][4],f[i-1][5]});
		}
		else 
		{
			f[i][0]=2e18;
			f[i][3]=min({f[i-1][0]+1,f[i-1][1]+1,f[i-1][2]+1,f[i-1][3],f[i-1][4],f[i-1][5]});
		}
		if(t[i]=='0')
		{
			f[i][2]=2e18;
			f[i][1]=min({f[i-1][0]+1,f[i-1][1],f[i-1][2]+1,f[i-1][3]+1,f[i-1][4],f[i-1][5]+1});
			f[i][4]=2e18;
			f[i][5]=min({f[i-1][0]+2,f[i-1][1]+2,f[i-1][2]+1,f[i-1][3]+1,f[i-1][4]+1,f[i-1][5]});
		}
		else
		{
			f[i][1]=2e18;
			f[i][2]=min({f[i-1][0]+1,f[i-1][1]+1,f[i-1][2],f[i-1][3]+1,f[i-1][4]+1,f[i-1][5]});
			f[i][5]=2e18;
			f[i][4]=min({f[i-1][0]+2,f[i-1][1]+1,f[i-1][2]+2,f[i-1][3]+1,f[i-1][4],f[i-1][5]+1});
		}
	}
	cout<<min({f[n][0],f[n][1],f[n][2],f[n][3],f[n][4],f[n][5]});
	putchar('\n');
	return 0;
}

